package com.ys.otms.controller;

import com.ys.otms.services.IDeductionsServices;
import com.ys.otms.services.IHuoYuanServices;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2018/10/29.
 */
@Controller
@RequestMapping("/deductions")
public class DeductionsController {
    private static Logger logger = LoggerFactory.getLogger(DeductionsController.class);


    @Autowired
    private IDeductionsServices iDeductionsServices;
    /**
     * 生成订单
     * @param request
     * @return
     */
    @RequestMapping("/generatingOrder")
    @ResponseBody
    public JSONObject generatingOrder(HttpServletRequest request) throws Exception {
        logger.info("DeductionsController generatingOrder start");
        JSONObject jsonDeductions = new JSONObject();
        try {
            jsonDeductions = iDeductionsServices.generatingOrder(request);
        } catch (Exception e) {
            logger.error("DeductionsController generatingOrder error", e);
            jsonDeductions.put("SUCCESS",false);
            jsonDeductions.put("MSG","订单生成失败！");
        }
        return jsonDeductions;
    }
}

